package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author Feng
 * @date 2023/4/27
 * 资产方位
 */
@Getter
@AllArgsConstructor
public enum EquipmentPosition {

    PACKAGE(1, "整套"),
    SALON(2, "厅"),
    AISLE(3, "过道"),
    BALCONY(4, "阳台"),
    BEDROOM(5, "次卧"),
    MASTER_BEDROOM(6, "主卧"),
    TOILET(7, "卫"),
    KITCHEN(8, "厨"),
    OTHER(9, "其他");

    private int code;
    private String name;

    public static String getNameByCode(String code) {
        if (StrUtil.isEmpty(code)) {
            return null;
        }
        Optional<EquipmentPosition> find = Arrays.stream(EquipmentPosition.values()).filter(s -> (s.getCode()+"").equals(code)).findFirst();
        if (find.isPresent()) {
            return find.get().getName();
        }
        return null;
    }
}
